#include "Camera.h"


Camera::Camera(int _left,int _right,int _height)
{	
	
	left = _left;
	right = _right;
	vp_y = _height;
	D3DXMatrixIdentity(&this->matrixI4);
	matrixI4._22 = -1;
}


Camera::~Camera(void)
{
}

void Camera::Update(D3DXVECTOR2 target)
{	
// 	if(target.x > right - DY) return;
// 	vp_x = target.x - CENTER;
// 	if(vp_x < left) vp_x = left;
// 
// 	if(target.x > left + CENTER)
// 	{		
// 		left = vp_x;
// 	}
	vp_x = target.x - CENTER;
	if(vp_x < 0) vp_x = 0;
	if(vp_x > (right - 3 * CENTER))
		vp_x =(right - 3 * CENTER); 

}

D3DXMATRIX* Camera::getTransformedMatrix()
{
	D3DXMATRIX transfromMatrix;
	D3DXMatrixTranslation(&transfromMatrix,-vp_x,vp_y,0);
	//nhan nguoc
	D3DXMatrixMultiply(&this->transform,&matrixI4,&transfromMatrix);
	return &transform;

}

float Camera::getLeftSide()
{
	return left;
}

float Camera::getRightSide()
{
	return left + LOOK;
}
